package com.meilai.project.service.business.customer;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.meilai.project.controller.mini.vo.customer.MiniCustomerInfoVO;
import com.meilai.project.controller.web.businessFlow.dto.BFCustomerSearchParams;
import com.meilai.project.dto.business.contract.ContractInfoForCustomerDTO;
import com.meilai.project.dto.business.customer.CustomerInfoDTO;
import com.meilai.project.dto.business.customer.CustomerInfoFlowDTO;
import com.meilai.project.entity.business.customer.CustomerInfo;
import com.meilai.project.entity.business.customer.CustomerVisitComments;
import com.meilai.project.vo.business.customer.*;
import com.meilai.project.vo.business.workbench.BaseWeekCustomerVO;

import java.time.LocalDate;
import java.util.List;

/**
 * <p>
 * 客户信息表 服务类
 * </p>
 *
 * @author xhy
 * @since 2022-01-06
 */
public interface CustomerInfoService extends IService<CustomerInfo> {

//    /**
//     * 保存客户信息
//     * @param dto
//     * @return
//     */
//    Boolean save(CustomerInfoFlowDTO dto);

    /**
     * 保存或修改客户信息
     *
     * @param dto
     * @return
     */
    Boolean saveOrUpdate(CustomerInfoFlowDTO dto);

    /**
     * 分页查询
     *
     * @param current_page
     * @param page_size
     * @return
     */
    Page<CustomerInfoVO> page(Integer current_page, Integer page_size, String name, Long industry_id, Boolean is_my_customer_page, Integer type, Long maintenance_staff_id);

    /**
     * 业务流使用
     */
    Page<CustomerInfoVO> pageForBF(BFCustomerSearchParams params);

    List<CustomerInfo> listAll();

    List<CustomerInfo> companyListAll();

    // 根据客户id，查询合同信息（时间倒序）
    List<ContractInfoForCustomerDTO> getContractInfosByCustomerId(Long customerId);

    /**
     * 跟进客户id获取客户信息
     *
     * @param id
     * @return
     */
    CustomerInfoDTO getOneDtoById(Long id);

    /**
     * 指派销售
     *
     * @param id
     * @param maintenance_staff_id
     * @return
     */
    Boolean edit(Long id, Long maintenance_staff_id);

    /**
     * 获取所有客户
     *
     * @param current_page
     * @param page_size
     * @param name
     * @param industry_id
     * @param follow_up
     * @return
     */
    Page<CustomerInfoVO> allPage(Integer current_page, Integer page_size, String name, Long industry_id, Boolean follow_up, Long deptId);


    /**
     * 查询时间段内的用户维护的需要拜访的客户信息
     *
     * @param userId
     * @param type
     * @param begin_date
     * @param end_date
     * @return
     */
    List<BaseWeekCustomerVO> queryCustomerInfoByDate(Long userId, Integer type, LocalDate begin_date, LocalDate end_date);

    /**
     * 获取本人客户推进动作数据
     *
     * @return
     */
    List<CustomerAdvanceVO> advanceList();

    Page<CustomerFollowVO> visitRecordList(Integer current_page, Integer page_size, Long customer_id, String contact_name, LocalDate begin_date, LocalDate end_date);

    List<CompanyCustomerAdvanceVO> companyAdvanceList(Integer year, Integer month, List<Long> ids);

    List<String> getContactById(Long id);

    List<CustomerInfoScheduledJobVO> selectList();

    Page<CustomerVisitComments> visitCommentsPage(Integer current_page, Integer page_size, Long customer_id, String comments);

    /**
     * 根据客户ID检查客户是否有流程
     *
     * @param customer_id
     * @return
     */
    Boolean queryCustomerFlow(Long customer_id);

    MiniCustomerInfoVO getDeteil(Long id);

    List<CompanyCustomerAdvanceVO> queryCustomerInfoPage(Page<CompanyCustomerAdvanceVO> page, Integer type, List<Long> boss_ids, String name, Long user_id);

    List<CompanyCustomerAdvanceVO> queryCustomerInfoPageOrderByFollowDesc(Page<CompanyCustomerAdvanceVO> page, Integer type, List<Long> boss_ids, String name, Long user_id);

    List<CustomerInfo> companyListAll(Integer type);
}
